package com.syedu.day03;

/**
 * @Description JDK内置进制转换工具
 * @createTime 2022/3/7 13:48
 * @author Administrator
 */
public class IntegerDemo {
    public static void main(String[] args) {
        //十进制转二进制,把十进制的数字转换成二进制字符串表示
        String toBinaryString = Integer.toBinaryString(-8);
        System.out.println(toBinaryString);

        String toOctalString = Integer.toOctalString(8);
        System.out.println(toOctalString);

        String toHexString = Integer.toHexString(15);
        System.out.println(toHexString);

        //任何进制转换成十进制,第一个参数是进制字符串,第二个参数表示几进制,结果是十进制
        int result = Integer.parseInt("1011", 2);
        System.out.println(result);

        //十六进制赋值
        int i = 0x111;
        System.out.println(i);

        //八进制赋值
        int j = 032;
        System.out.println(j);
    }
}
